home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / src / GLperf3.12-src.lha / GLperf / ClearX.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-01  |  5.1 KB  |  159 lines

  1. /*
  2.  * (c) Copyright 1995, Silicon Graphics, Inc.
  3.  * ALL RIGHTS RESERVED
  4.  * Permission to use, copy, modify, and distribute this software for
  5.  * any purpose and without fee is hereby granted, provided that the above
  6.  * copyright notice appear in all copies and that both the copyright notice
  7.  * and this permission notice appear in supporting documentation, and that
  8.  * the name of Silicon Graphics, Inc. not be used in advertising
  9.  * or publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.
  11.  *
  12.  * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
  13.  * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
  14.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
  15.  * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
  16.  * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
  17.  * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
  18.  * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
  19.  * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
  20.  * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
  21.  * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
  22.  * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
  23.  * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
  24.  *
  25.  * US Government Users Restricted Rights
  26.  * Use, duplication, or disclosure by the Government is subject to
  27.  * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
  28.  * (c)(1)(ii) of the Rights in Technical Data and Computer Software
  29.  * clause at DFARS 252.227-7013 and/or in similar or successor
  30.  * clauses in the FAR or the DOD or NASA FAR Supplement.
  31.  * Unpublished-- rights reserved under the copyright laws of the
  32.  * United States.  Contractor/manufacturer is Silicon Graphics,
  33.  * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
  34.  *
  35.  * Author: John Spitzer, SGI Applied Engineering
  36.  *
  37.  */
  38.  
  39. /* Define calls if using function pointers or not */
  40. #ifdef FUNCTION_PTRS
  41.   #define CLEAR_CALL   (*clear)(mask);
  42.   #ifdef POINT_DRAW
  43.     #define VERTEX_CALL \
  44.       (*vertex3fv)(point1); \
  45.       (*vertex3fv)(point2); \
  46.       (*vertex3fv)(point3); \
  47.       (*vertex3fv)(point4);
  48.     #define BEGIN_CALL   (*begin)(GL_POINTS);
  49.     #define END_CALL     (*end)();
  50.   #endif
  51. #else
  52.   #define CLEAR_CALL   glClear(mask);
  53.   #ifdef POINT_DRAW
  54.     #define VERTEX_CALL  \
  55.       glVertex3fv(point1); \
  56.       glVertex3fv(point2); \
  57.       glVertex3fv(point3); \
  58.       glVertex3fv(point4);
  59.     #define BEGIN_CALL   glBegin(GL_POINTS);
  60.     #define END_CALL     glEnd();
  61.   #endif
  62. #endif
  63.  
  64. #ifdef POINT_DRAW
  65.   #define DEFINE_POINTS \
  66.     GLfloat point1[3] = { -0.99, -0.99, -1.0 }; \
  67.     GLfloat point2[3] = {  0.99, -0.99, -1.0 }; \
  68.     GLfloat point3[3] = { -0.99,  0.99, -1.0 }; \
  69.     GLfloat point4[3] = {  0.99,  0.99, -1.0 };
  70.   #define CLEAR  \
  71.     BEGIN_CALL   \
  72.     VERTEX_CALL  \
  73.     END_CALL     \
  74.     CLEAR_CALL
  75. #else
  76.   #define DEFINE_POINTS
  77.   #define CLEAR  \
  78.     CLEAR_CALL
  79. #endif
  80.  
  81. /* Unroll the clears to the number specified */
  82. #if (UNROLL == 1)
  83.   #define UNROLLED_CLEARS CLEAR
  84.   #define DEFINE_CLEANUP
  85. #elif (UNROLL == 2)
  86.   #define UNROLLED_CLEARS CLEAR CLEAR
  87.   #define DEFINE_CLEANUP int remainingClears = iterations & 1;
  88. #elif (UNROLL == 3)
  89.   #define UNROLLED_CLEARS CLEAR CLEAR CLEAR
  90.   #define DEFINE_CLEANUP int remainingClears = iterations % 3;
  91. #elif (UNROLL == 4)
  92.   #define UNROLLED_CLEARS CLEAR CLEAR CLEAR CLEAR
  93.   #define DEFINE_CLEANUP int remainingClears = iterations & 3;
  94. #elif (UNROLL == 5)
  95.   #define UNROLLED_CLEARS CLEAR CLEAR CLEAR CLEAR CLEAR
  96.   #define DEFINE_CLEANUP int remainingClears = iterations % 5;
  97. #elif (UNROLL == 6)
  98.   #define UNROLLED_CLEARS CLEAR CLEAR CLEAR CLEAR CLEAR CLEAR
  99.   #define DEFINE_CLEANUP int remainingClears = iterations % 6;
  100. #elif (UNROLL == 7)
  101.   #define UNROLLED_CLEARS CLEAR CLEAR CLEAR CLEAR CLEAR CLEAR CLEAR
  102.   #define DEFINE_CLEANUP int remainingClears = iterations % 7;
  103. #elif (UNROLL == 8)
  104.   #define UNROLLED_CLEARS CLEAR CLEAR CLEAR CLEAR CLEAR CLEAR CLEAR CLEAR
  105.   #define DEFINE_CLEANUP int remainingClears = iterations & 7;
  106. #endif
  107.  
  108. #if (UNROLL > 1)
  109.   #define CLEANUP_LOOP \
  110.     for (i=remainingClears; i>0; i--) { \
  111.       CLEAR \
  112.     }
  113. #else
  114.   #define CLEANUP_LOOP
  115. #endif
  116.  
  117. void FUNCTION (TestPtr thisTest)
  118. {
  119.     ClearPtr this = (ClearPtr)thisTest;
  120.     int iterations = this->iterations;
  121.     int loops = iterations/UNROLL;
  122.     int mask = this->mask;
  123.     int i;
  124.     DEFINE_POINTS
  125.     DEFINE_CLEANUP
  126.   #ifdef FUNCTION_PTRS
  127.   #ifdef WIN32
  128.     #ifdef POINT_DRAW
  129.       void (APIENTRY *vertex3fv)(const GLfloat*) = glVertex3fv;
  130.       void (APIENTRY *begin)(GLenum) = glBegin;
  131.       void (APIENTRY *end)(void) = glEnd;
  132.     #endif
  133.     void (APIENTRY *clear)(GLbitfield) = glClear;
  134.    #else
  135.     #ifdef POINT_DRAW
  136.       void (*vertex3fv)(const GLfloat*) = glVertex3fv;
  137.       void (*begin)(GLenum) = glBegin;
  138.       void (*end)(void) = glEnd;
  139.     #endif
  140.     void (*clear)(GLbitfield) = glClear;
  141.    #endif
  142.   #endif
  143.  
  144.     for (i=loops; i>0; i--) {
  145.         UNROLLED_CLEARS
  146.     }
  147.     CLEANUP_LOOP
  148. }
  149.  
  150. #undef CLEAR_CALL
  151. #undef BEGIN_CALL
  152. #undef END_CALL
  153. #undef VERTEX_CALL
  154. #undef CLEAR
  155. #undef UNROLLED_CLEARS
  156. #undef DEFINE_POINTS
  157. #undef DEFINE_CLEANUP
  158. #undef CLEANUP_LOOP
  159.